import { FormInstance, FormRules } from "element-plus"
import { reactive, ref } from "vue"

export const useLoginForm = () => {


  const loginFormRef = ref<FormInstance>()

  const loginForm = reactive({
    account: 'weiwei666',
    password: '8848',
  })

  const loginFormRule = reactive<FormRules>({
    account: [
      {
        required: true,
        message: '请输入账号',
      },
    ],
    password: [
      {
        required: true,
        message: '请输入密码',
      },
    ],
  })

  return {
    loginFormRef,
    loginForm,
    loginFormRule
  }
}


export const useRegisterForm = () => {
  const registerFormRef = ref<FormInstance>()

  const registerFormRule: FormRules = {
    nickname: {
      required: true,
      message: '请输入名称',
    },
    account: {
      required: true,
      message: '请输入账号',
    },
    password: {
      required: true,
      message: '请输入密码',
    },
  }

  const registerForm = reactive({
    nickname: '',
    account: '',
    password: '',
  })

  return {
    registerFormRef,
    registerFormRule,
    registerForm
  }
}